/*
 * Powered By [rapid-framework]
 * Web Site: http://www.rapid-framework.org.cn
 * Google Code: http://code.google.com/p/rapid-framework/
 * Since 2008 - 2013
 */

package com.smg.community.dao;

import java.util.*;

import javacommon.base.*;
import javacommon.util.*;

import cn.org.rapid_framework.util.*;
import cn.org.rapid_framework.web.util.*;
import cn.org.rapid_framework.page.*;
import cn.org.rapid_framework.page.impl.*;

import com.smg.community.model.*;
import com.smg.community.dao.*;
import com.smg.community.service.*;
import com.smg.community.vo.query.*;

/**
 * @author badqiu email:badqiu(a)gmail.com
 * @version 1.0
 * @since 1.0
 */


import org.springframework.stereotype.Repository;


@Repository
public class SmgTopicDao extends BaseIbatis3Dao<SmgTopic,java.lang.Integer>{
	
	@Override
	public String getIbatisMapperNamesapce() {
		return "SmgTopic";
	}
	
	public void saveOrUpdate(SmgTopic entity) {
		if(entity.getTopicId() == null) 
			save(entity);
		else 
			update(entity);
	}
	
	public Page findPage(SmgTopicQuery query) {
		return pageQuery("SmgTopic.findPage",query);
	}

	public List<SmgTopic> getByQuery(SmgTopicQuery query) {
		return this.getSqlSessionTemplate().selectList("SmgTopic.getByQuery", query);
	}

	public List<SmgTopic> getFourHotTopicList(int cityNo) {
		
		return this.getSqlSessionTemplate().selectList("SmgTopic.getFourHotTopicList", cityNo);
	}


	public void updateClickCount(int topicId) {
		this.getSqlSessionTemplate().update("SmgTopic.updateClickCount", topicId);
	}

	public int getReplyCountById(int topicId) {
		return (Integer)this.getSqlSessionTemplate().selectOne("SmgTopic.getReplyCountById", topicId);
	}

	public Page<SmgTopic> findActivityPage(SmgTopicQuery query) {
		return pageQuery("SmgTopic.findActivityPage",query);
	}

	public List<SmgTopic> getThreeActivityList(int cityNo) {
		return  (List<SmgTopic>)this.getSqlSessionTemplate().selectList("SmgTopic.getThreeActivityList",cityNo);
	}

	public Page<SmgTopic> findMemberJioinActivityPage(SmgTopicQuery query) {
		return pageQuery("SmgTopic.findMemberJioinActivityPage",query);
	}

	public Page<SmgTopic> findMemberReplyTopicPage(SmgTopicQuery query) {
		return pageQuery("SmgTopic.findMemberReplyTopicPage",query);
	}

	public void updateTopType(SmgTopic topic) {
		this.getSqlSessionTemplate().update("SmgTopic.updateTopType", topic);
	}

	public void updateTopicTitleAndCont(SmgTopic topic) {
		this.getSqlSessionTemplate().update("SmgTopic.updateTopicTitleAndCont", topic);
	}
	

}
